< previous page page_283 next page >

Page 283
0283-01.jpg
Figure 8.13.
Using the 
WHERE clause to link three tables.
In the previous example, the Publishers table and the Titles table are linked using the PubID column. The Titles table and the Authors table are linked using the AUID field. When the link is made, the selected columns are displayed in the result set.
You might have noticed that SQL assigns column names to the result sets. There are times when these assigned names can be misleading or incomplete. You can use the AS keyword to rename the columns in the result set. The following SQL statement is one example of using the AS keyword in the SELECT statement to rename the column headers of the result set. This renaming does not affect the original column names in the underlying tables. Execute the following SQL statement and compare your results to those in Figure 8.14.
SELECT Titles.PubID AS PubCode,    Titles.Title AS BookTitle,
   Publishers.Name AS PubName,
   Authors.Name AS AuthorName
   FROM Titles, Publishers,Authors
   WHERE Titles.PubID = Publishers.PubID
      AND Titles.AUID = Authors.AUID
0283-02.jpg
Figure 8.14.
Using the 
AS keyword to rename columns in the result set.

 
< previous page page_283 next page >

If you like this book, buy it!